{include file="Public:header2"/}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <form method="get" team="{:url('/admin/climb')}" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">                
                <div class="layui-inline">
                    <div class="layui-input-block">
                        <input type="text" name="keyword" value="{$Request.get.keyword}" placeholder="请输入盒子标题" autocomplete="off" class="layui-input">
                    </div>
                </div>   
               
                <div class="layui-inline">
                    <div class="layui-input-block">
                        <select name="status" style="width:100%">
                            <option value="">--请选择状态--</option>
                            <option value="1" {if condition="$Request.get.status eq 1"}selected{/if}>正常</option>
                            <option value="2" {if condition="$Request.get.status eq 2"}selected{/if}>下架</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin mmm" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </form>

        <div class="layui-card-body">
            <xblock>
                <div style="padding-bottom: 10px;">
                    <a class="layui-btn" href="javascript:;"  onclick="add_goods()" >添加盒子</a>
                    <span style="line-height:40px;float:right;">共有数据： {$count}条</span>
                </div>
            </xblock>
            <table class="layui-table">
                <thead>
                <tr>
                    <th>盒子ID</th>
                    <th>盒子名称</th>
                    <th>盒子封面</th>
                    <th>层数</th>
                    <th>状态</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                    <tr>
                        <td>{$vo['id']}</td>
                        <td>{$vo['title']}</td>
                        <td><img src="{PHP} echo imageUrl($vo['imgurl']){/php}" style="width:60px;height:60px;"></td>
                        <td>{$vo['floors_num']}</td>
                        <td>
                            {if condition="$vo['status'] eq 1"}
                                <button class="layui-btn layui-btn-normal layui-btn-radius layui-btn-sm">启用</button>
                            {elseif  condition="$vo['status'] eq 2" /}
                                <button class="layui-btn layui-btn-default layui-btn-radius layui-btn-sm">下架</button>
                            {elseif  condition="$vo['status'] eq 3" /}
                                <button class="layui-btn layui-btn-disabled layui-btn-radius layui-btn-sm">已结束</button>
                            {elseif  condition="$vo['status'] eq 0" /}
                                <button class="layui-btn layui-btn-default layui-btn-radius layui-btn-sm">未启用</button>
                            {/if}
                        </td>
                        <td>{$vo['addtime']}</td>
                        <td>{$vo['end_time']}</td>
                        <td>
                            <a style="text-decoration:none" title="塔层奖品" href="javascript:;" onclick="level_prize({$vo['id']})" class="layui-btn layui-btn-radius layui-btn-normal layui-btn-xs">塔层奖品</a>
                            <a style="text-decoration:none" title="通关奖励" href="javascript:;" onclick="end_prize({$vo['id']})"   class="layui-btn layui-btn-radius layui-btn-warm layui-btn-xs">通关奖励</a>
                            <!--<a style="text-decoration:none" title="编辑" href="javascript:;"  onclick="goods_edit({$vo['id']})"  class="layui-btn layui-btn-radius layui-btn-default layui-btn-xs">编辑</a>-->

                            {if condition="$vo['status'] eq 0"}
                                <a style="text-decoration:none" title="编辑" href="javascript:;"  onclick="goods_edit({$vo['id']})"  class="layui-btn layui-btn-radius layui-btn-default layui-btn-xs">编辑</a>
                                <button onClick="del({$vo.id},'1')" class="layui-btn layui-btn-radius layui-btn-danger layui-btn-xs"><i class="layui-icon">&#xe619;</i>启用</button>
                            {else /}
                                <button onClick="del({$vo.id},'3')" class="layui-btn layui-btn-radius layui-btn-danger layui-btn-xs"><i class="layui-icon">&#xe61a;</i>结束</button>
                            {/if}
                            <a style="text-decoration:none" title="操作" onClick="del({$vo.id},'4')" class="layui-btn layui-btn-radius layui-btn-danger layui-btn-xs"> 删除</a>
                            <!-- <a style="text-decoration:none" title="开盒记录" href="javascript:;" onclick="tan_tiao('开盒记录','{:url('/admin/climb_order',['id'=>$vo['id']])}')" class="layui-btn layui-btn-normal layui-btn-xs">开盒记录</a> -->
                        </td>
                    </tr>
                {/volist}

                {if condition="empty($list)"}
                    <tr><td colspan='11' style="text-align:center;">暂时没有数据！</td></tr>
                {/if}
               
                </tbody>
            </table>
            <div class="layui-box layui-laypage layui-laypage-default">
                {$page|raw}
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
<script type="text/javascript">
    layui.use(['layer','table'], function(){
        var $ = layui.$;
        
    })
    
    //上下架
    function del(id,type){
        if(type==1){
            var title = "启用";
        }else if(type==3){
            var title = "关闭";
        }else if(type==4){
            var title = "删除";
        }
        layer.confirm('确认要执行'+title+'操作吗？',function(){
            var url = "{:url('/admin/climb_cao')}";
            var load=layer.load(2);
            var $ = layui.$;
            $.post(url,{"id":id,'type':type},function(data){
                if(data.status == 1){
                    layer.msg(title+'成功',{icon:1,time:1000},function(){
                        location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon:2,anim:6,time:1000},function(){
                        layer.close(load);
                    });
                }
            })
        });
    }


    //新增盒子
    function add_goods() {
        var url  = "{:url('/admin/climb_add')}";
        layer.open({
            type: 2,
            title: '新增盒子',
            shadeClose: false,
            shade: 0.3,
            area: ['90%', '90%'],
            content: url,
        });
    }

    //层级奖品
    function goods_edit(id) {
        var url  = "{:url('/admin/climb_edit?goods_id="+id+"')}";
        layer.open({
            type: 2,
            title: '层级奖品',
            shadeClose: false,
            shade: 0.3,
            area: ['90%', '90%'],
            content: url,
        });
    }

    //层级奖品
    function level_prize(id) {
        var url  = "{:url('/admin/climb_prize?goods_id="+id+"')}";
        layer.open({
            type: 2,
            title: '层级奖品',
            shadeClose: false,
            shade: 0.3,
            area: ['90%', '90%'],
            content: url,
        });
    }
    
    //最后奖品
    function end_prize(id) {
        var url  = "{:url('/admin/climb_list?goods_id="+id+"&num=0')}";
        layer.open({
            type: 2,
            title: '通关奖品',
            shadeClose: false,
            shade: 0.3,
            area: ['90%', '90%'],
            content: url,
        });
    }


    //切换消费后可见
    function show(id,type){
        if(type==1){
            var title = "确认调整消费后可见";
        }else if(type==2){
            var title = "确认调整所有人可见";
        }
        layer.confirm(title+'？',function(){
            var url = "{:url('/admin/climb_show')}";
            var load=layer.load(2);
            var $ = layui.$;
            $.post(url,{"id":id,'type':type},function(data){
                if(data.status == 1){
                    layer.msg('操作成功',{icon:1,time:1000},function(){
                        location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon:2,anim:6,time:1000},function(){
                        layer.close(load);
                    });
                }
            })
        });
    }
</script>
</body>
</html>


